package com.zxl.mmm;

import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class DateUtil {
    
    private static SimpleDateFormat DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd");
    
    private static List<String> FESTIVALS = Arrays.asList(""); 
    
    
    
    /**
     * 日期转字符串
     * @return
     */
    public static String date2Str(Date date){
        return DATEFORMAT.format(date);
    }
    
    /**
     * 是否节假日
     * @return
     */
    public static boolean isHolidays(Date date) {
        return isFestivals(date) || isWeekend(date);
    }
    
    /**
     * 是否是法定假日
     * @return
     */
    public static boolean isFestivals(Date date){
        return FESTIVALS.contains(date2Str(date));
    }
    
    /**
     * 是否是周末
     * @param date
     * @return
     */
    public static boolean isWeekend(Date date){
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        int i = calendar.get(Calendar.DAY_OF_WEEK);
        return i == Calendar.SATURDAY || i == Calendar.SUNDAY;
        
    }
    
    public static void main(String[] args) {
    }
}
